<%-- 
    Document   : astaDetails
    Created on : 4-gen-2013, 16.40.17
    Author     : Luciano
--%>


<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Locale"%>
<%@page import="java.util.Date"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.Offer"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.UM"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.Asta"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.User"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.Product"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.DBManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

        <%
        Offer o;
        if(request.getAttribute("offer")!=null){
            o=(Offer)request.getAttribute("offer");
        }else if(session.getAttribute("offer")!=null){
            o=(Offer)session.getAttribute("offer");
            session.removeAttribute("offer");
        }else{
            request.setAttribute("error_message", "Unable to find your offer");
            throw new Exception();
        }
        String mess="";
         if(request.getAttribute("mess")!=null){
            mess=(String)request.getAttribute("mess");
         }else if(session.getAttribute("mess")!=null){
            mess=(String)session.getAttribute("mess");
            session.removeAttribute("mess");
         }
        %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Offer Details</title>
    </head>
    <body>
        <h2>Offer details</h2>
        <h3><%=mess%></h3>
        <div class="content">
            <a href="<%=response.encodeURL(request.getContextPath()+"/contents/user/productDetails?id="+o.getAsta().getProductId())%>"
                ><h3><%=o.getAsta().getProduct().getName()%></h3>
            </a> 
            <img src="<%=request.getContextPath()%>/immagini/prodotti/<%=o.getAsta().getProduct().getImageName()%>"/>
            <div class="details">
                <table>
                    <tr>
                        <td><h3>Offer:</h3></td>
                        <td><h3>Asta:</h3></td>
                    </tr>
                    <tr>
                    <td>
                <h4>By:</h4>
                    <a href="<%=response.encodeURL(request.getContextPath()+"/contents/user/userDetails?id="+o.getBuyerId())%>"
                           ><p><%=o.getBuyer().getUsername()%></p>
                    </a> 
                <h4>Actual offer:</h4><p><%=o.getActualPrice()%></p>
                <h4>Max offer</h4><p><%=o.getMaxPrice()%></p>
                <h4>At:</h4><p> <%=o.getHumanDate()%></p>
                </td>
                <td>
                <h4>Number</h4>
                    <a href="<%=response.encodeURL(request.getContextPath()+"/contents/user/astaDetails?id="+o.getAstaId())%>"
                           ><p>number <%=o.getAstaId()%></p> 
                    </a> 
                <h4>Deadline</h4><p><%=o.getAsta().getHumanDeadline()%></p>
                <h4>Quantity:</h4><p> <%=o.getAsta().getQuantity()%></p>
                </td>
                    </tr></table>
            </div>
        </div>
    </body>
</html>
